package service

import (
	"fmt"
	"strings"
)

type Daemon struct {
	Name     string
	StartCmd string
	StartDir string
}

var DaemonMap = make(map[string]*Daemon)

func loadDaemons() {
	for _, app := range Conf.Client.Daemons {
		appSlice := strings.Split(app, ",")
		if len(appSlice) != 3 {
			appSlice := strings.Split(app, Conf.Client.Sep)
			if len(appSlice) != 3 {
				Logger.Fatal("Daemon配置不合法")
			}
		}

		d := &Daemon{
			Name:     appSlice[0],
			StartCmd: appSlice[1],
			StartDir: appSlice[2],
		}

		DaemonMap[d.Name] = d
	}

	for _, v := range DaemonMap {
		fmt.Printf("即将监控的Daemon:%#v\n", v)
	}
}
